
package com.quartet.modules.system.domain;

import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import com.quartet.base.BaseEntity;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Set;

/**
 * @author Zheng Jie
 * @date 2018-11-22
 */
@Entity
@Getter
@Setter
@Table(name="sys_user")
public class User extends BaseEntity implements Serializable {

//    @Id
//    @Column(name = "user_id")
//    @NotNull(groups = Update.class)
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    @ApiModelProperty(value = "ID", hidden = true)
//    private Long id;
//
//    @ManyToMany
//    @ApiModelProperty(value = "用户角色")
//    @JoinTable(name = "sys_users_roles",
//            joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")},
//            inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")})
//    private Set<Role> roles;
//
//    @ManyToMany
//    @ApiModelProperty(value = "用户岗位")
//    @JoinTable(name = "sys_users_jobs",
//            joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")},
//            inverseJoinColumns = {@JoinColumn(name = "job_id",referencedColumnName = "job_id")})
//    private Set<Job> jobs;
//
//    @OneToOne
//    @JoinColumn(name = "dept_id")
//    @ApiModelProperty(value = "用户部门")
//    private Dept dept;
//
//    @NotBlank
//    @Column(unique = true)
//    @ApiModelProperty(value = "用户名称")
//    private String username;
//
//    @NotBlank
//    @ApiModelProperty(value = "用户昵称")
//    private String nickName;
//
//    @Email
//    @NotBlank
//    @ApiModelProperty(value = "邮箱")
//    private String email;
//
//    @NotBlank
//    @ApiModelProperty(value = "电话号码")
//    private String phone;
//
//    @ApiModelProperty(value = "用户性别")
//    private String gender;

//    @ApiModelProperty(value = "头像真实名称",hidden = true)
//    private String avatarName;
//
//    @ApiModelProperty(value = "头像存储的路径", hidden = true)
//    private String avatarPath;

//    @ApiModelProperty(value = "密码")
//    private String password;

//    @NotNull
//    @ApiModelProperty(value = "是否启用")
//    private Boolean enabled;

//    @ApiModelProperty(value = "是否为admin账号", hidden = true)
//    private Boolean isAdmin = false;

//    @Column(name = "pwd_reset_time")
//    @ApiModelProperty(value = "最后修改密码的时间", hidden = true)
//    private Date pwdResetTime;
//
//    @Override
//    public boolean equals(Object o) {
//        if (this == o) {
//            return true;
//        }
//        if (o == null || getClass() != o.getClass()) {
//            return false;
//        }
//        User user = (User) o;
//        return Objects.equals(id, user.id) &&
//                Objects.equals(username, user.username);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(id, username);
//    }

    /**
     * 主键id
     */
    @Id
    @ApiModelProperty(value = "主键id")
    @Column(name = "user_id")
    private Long id;

    @ManyToMany
    @ApiModelProperty(value = "用户角色")
    @JoinTable(name = "sys_users_roles",
            joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")},
            inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")})
    private Set<Role> roles;

    @ManyToMany
    @ApiModelProperty(value = "用户岗位")
    @JoinTable(name = "sys_users_jobs",
            joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")},
            inverseJoinColumns = {@JoinColumn(name = "job_id",referencedColumnName = "job_id")})
    private Set<Job> jobs;

    @OneToOne
    @JoinColumn(name = "dept_id")
    @ApiModelProperty(value = "用户部门")
    private Dept dept;

    /**
     * 用户名称
     */
    @ApiModelProperty(value = "用户名称")
    private String username;

    /**
     * 所属客户编码
     */
    @ApiModelProperty(value = "所属客户编码")
    private String customerCode;

    /**
     * 角色id
     */
    @ApiModelProperty(value = "角色id")
    private String roleId;

    /**
     * 账号等级
     */
    @ApiModelProperty(value = "账号等级")
    private Integer accountLevel;

    /**
     * 手机号码
     */
    @ApiModelProperty(value = "手机号码")
    private String phone;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱")
    private String email;

    /**
     * 联系人
     */
    @ApiModelProperty(value = "联系人")
    private String contacts;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String password;

    /**
     * 用户状态 1：启用 2：停用 3：过期 4：将要过期
     */
    @ApiModelProperty(value = "用户状态 1：启用 2：停用 3：过期 4：将要过期")
    private Integer userStatus;

    /**
     * 注册时间
     */
    @ApiModelProperty(value = "注册时间")
    private LocalDateTime registrationTime;

    /**
     * 过期时间
     */
    @ApiModelProperty(value = "过期时间")
    private LocalDateTime expireTime;

    /**
     * 公司名称
     */
    @ApiModelProperty(value = "公司名称")
    private String corporateName;

    /**
     * 行业应用
     */
    @ApiModelProperty(value = "行业应用")
    private String industryApplication;

    /**
     * 公司地址
     */
    @ApiModelProperty(value = "公司地址")
    private String companyAddress;

    @NotNull
    @ApiModelProperty(value = "是否启用")
    private Boolean enabled;

    @ApiModelProperty(value = "用户性别")
    private String gender;

    @ApiModelProperty(value = "用户昵称")
    private String nickName;

    @ApiModelProperty(value = "头像真实名称",hidden = true)
    private String avatarName;

    @ApiModelProperty(value = "头像存储的路径", hidden = true)
    private String avatarPath;

    @ApiModelProperty(value = "最后修改密码的时间", hidden = true)
    private Date pwdResetTime;

    @ApiModelProperty(value = "是否为admin账号", hidden = true)
    private Boolean isAdmin = false;
    /**
     * 删除标识 0未删除 1删除
     */
    @ApiModelProperty(value = "删除标识 0未删除 1删除")
    @TableLogic
    private Integer deleted;
}